import java.util.Scanner;

/**
 * @author zhaoqian
 * @create 2021/8/30 10:06
 */
public class password {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String str = in.nextLine();
            System.out.println(test(str));
        }
    }
    public static String test(String s){
        String ok= "OK";
        String ng="NG";
        int i=0;
        if (s.length()<8){
            return  ng;
        }
      if (s.matches(".*[a-z]{1,}.*") ){
          i++;
      }
      if (s.matches(".*[A-Z]{1,}.*")){
          i++;
      }
      if (s.matches(".*\\d{1,}.*")){
          i++;
      }
      if (s.matches(".*[~!$&*()_+-=|:;<@#:>%^]{1,}.*")){
          i++;
      }
      if (i>=3){
          return ok;
      }

        return null;
    }
}
